/**
 * 
 */
package org.swing.utility.jai.file;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
 * @author Quynh Nhu
 *
 */
public class FolderInfo implements Comparable {
	  private String folderName;

	  public FolderInfo(final File directory) {
	    folderName = directory.getName();
	  }

	  public String getFolderName() {
	    return folderName;
	  }

	  public String toString() {
	    return folderName.toString();
	  }

	  public static List getFolderInfo(final File[] files) {
	    ArrayList folderInfos = new ArrayList();
	    for (int i = 0; i < files.length; i++) {
	      File file = files[i];
	      folderInfos.add(new FolderInfo(file));
	    }
	    Collections.sort(folderInfos);
	    return folderInfos;
	  }

	  public int compareTo(final Object o) {
	    if (o instanceof FolderInfo) {
	      FolderInfo folder = (FolderInfo)o;
	      return folderName.compareTo(folder.folderName);
	    }
	    return -1;
	  }
	}
